package controller;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JComponent;

public class EditAccountKeyListener implements KeyListener {


	@Override
	public void keyPressed(KeyEvent e) {

	}

	@Override
	public void keyReleased(KeyEvent e) {

		String name = ((JComponent) e.getSource()).getName();
		switch (name){
		case "usertxt":
		{
			Engine.setText(15, e, "[a-zA-Z0-9].*");
		}break;

		case "passtxt" :
		{
			Engine.setText(15, e, "[a-zA-Z0-9].*");
		}break;

		case "firstname" :
		{
			Engine.setText(20, e, "[a-zA-Z 'éèàòùì].*");
		}break;

		case "secondname" :
		{
			Engine.setText(20, e, "[a-zA-Z 'éèàòùì].*");
		}break;

		case "indirizzo_txt" :
		{
			Engine.setText(50, e, "[a-zA-Z 0-9'éèàòùì].*");
		}break;
		case "citta_txt" :
		{
			Engine.setText(30, e, "[a-zA-Z 'éèàòùì].*");
		}break;
		case "provincia_txt" :
		{
			Engine.setText(2, e, "[a-zA-Z'éèàòùì].*");
		}break;
		case "telefono_txt" :
		{
			Engine.setText(16, e, "[+0-9-].*");
		}break;
		case "cap_txt" :
		{
			Engine.setText(5, e, "[0-9].*");
		}break;
		case "email_txt" :
		{
			Engine.setText(50, e, "[a-zA-Z0-9@.].*");
		}break;
		}
	}

	@Override
	public void keyTyped(KeyEvent e) {

	}


}